<?php
if($actPost=='update')
{
    $counts     = gpc_getStringArray('count');
}
$listcart       = array();
$listidupdate   = array();
$totalprice     = 0;
foreach($listidcart as $i=>$id)
{
    $product    = getProductById($id[0]);
    
    if(intval($counts[$i])>1)
    {
        $id[1]      = $counts[$i];
    }
    if($counts[$i]!=-1)
    {
        $listidupdate[] = array($id[0],$id[1]);
    }else
    {
        continue;
    }

    $product['iCount']      = $id[1];
    $product['totalprice']  = $id[1]*$product['cPrice'];
    $listcart[] = $product;
    $totalprice += $product['totalprice'];
    
}

if($actPost=='update')
{
    gpc_setSession('listid',$listidupdate);
    $countcart      = count($listidupdate);
}

function getProductById($id)
{
    global $dbsql,$language;
    $id         = intval($id);
    $sql_select = 'select * from tblproduct where iId='.$id;
    return $dbsql->query_fetch($sql_select);
}
?>